package javax.ztest;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @ClassName: ReflectService
 * @Description: 反射dome
 * @author: LangXing
 * @date: 2019-04-03 19:18
 * @Version 1.0
 */
public class ReflectService {



	public void sayHello(String name) {

		System.out.println("-----------------------");
		System.out.println("hello " + name);
	}

	public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException
			, InstantiationException, NoSuchMethodException, InvocationTargetException {

		System.out.println(System.getProperty("java.io.tmpdir"));

		Object service = Class.forName(ReflectService.class.getName()).newInstance();

		Method method = service.getClass().getMethod("sayHello", String.class);

		method.invoke(service, "函鑫");

		Method method1 = service.getClass().getMethod("inve");

		method1.invoke(service);

		Method method2 = service.getClass().getMethod("stb");

		method2.invoke(service);


	}


	public void inve(){

		System.out.println("***************");
		System.out.println(System.getProperty("user.dir"));
		System.out.println("***************");

	}

	public void stb(){
		String s = "12345678";
		StringBuffer sbf = new StringBuffer();
		sbf.append(s, 2, 4);
		System.out.println(sbf.toString());
	}
}
